package com.chenhao.springcloud.chenhaodatastructureservice.sort;

/**
 * Description:测试算法工具类
 *
 * @author chenhao
 * @date 2020/12/3 14:38
 */
public class SortingHelper {

    public static <E extends  Comparable<E>> void sortTest(String sortname,E[] arr){
        long startTime = System.nanoTime();
        if (sortname.equals("SelectionSort")){
            SelectionSort.sort(arr);
        }else if (sortname.equals("InsertionSort")){
            InsertionSort.sort(arr);
        }else if (sortname.equals("InsertionSort2")){
            InsertionSort.sort2(arr);
        }
        long endTime = System.nanoTime();

        double time = (endTime-startTime) /100000000.0;
        System.out.println(String.format("/%s,n= %d : %f s ",sortname,arr.length,time));
    }
}
